/*
 *  APanVolEffect.cpp
 *  libavid
 *
 *  Created by Peter on 26.02.12.
 *  Copyright 2012 __MyCompanyName__. All rights reserved.
 *
 */

#include "APanVolEffect.h"
#include "AStream.h"

A_IMPLEMENT_CLASS( 'PVOL', APanVolEffect, ATrackEffect );

void APanVolEffect::readFromStream( AStream& str, const AObjDoc& objd )
{
	ATrackEffect::readFromStream( str, objd );
	
	UInt8 tagMark, version;
	str.readPod( tagMark );
	str.readPod( version );
	TR_ASSERT( tagMark == 0x02 );
	TR_ASSERT( version == 5 );
	
	str.readPod( _level );
	str.readPod( _pan );
	_suppressValidation = str.readBool();
	_levelSet = str.readBool();
	_panSet = str.readBool();
	
	// PClass Ext DoesSupportSep
	str.readPod( tagMark );
	str.readPod( version );
	TR_ASSERT( tagMark == 0x01 );
	TR_ASSERT( version == 0x01 );
	str.readPod( tagMark );
	TR_ASSERT( tagMark == 71 );
	str.readPod( _doesSupportClipGain ); 
	
	// PClass Ext IsTrimGainEffe
	str.readPod( tagMark );
	str.readPod( version );
	TR_ASSERT( tagMark == 0x01 );
	TR_ASSERT( version == 0x02 );
	str.readPod( tagMark );
	TR_ASSERT( tagMark == 71 );	
	str.readPod( _isTrimGainEffect );
    
	// End TagMark
	str.readPod( tagMark );
	TR_ASSERT( tagMark == 0x03 );
}

#define TRACE_FIELD( x ) "\t" #x ": " << x << std::endl

void APanVolEffect::dump( std::ostream& str ) const
{
	str << "APanVolEffect |" << std::endl;
	
	str << "\t";
	ATrackEffect::dump( str );
	
	str << TRACE_FIELD( _level );
	str << TRACE_FIELD( _pan );
	str << TRACE_FIELD( _suppressValidation );
	str << TRACE_FIELD( _levelSet );
	str << TRACE_FIELD( _panSet );
	str << TRACE_FIELD( _doesSupportClipGain );
	str << TRACE_FIELD( _isTrimGainEffect );
	
	str << "}" << std::endl;
}